package com.anzia.stream;

import java.io.FileInputStream;
import java.io.ObjectInputStream;
import java.util.ArrayList;

/**
 *@ClassName com.anzia.stream.ObjectInputStream_Demo
 *@Description 使用ObjectInputStream实现反序列化（读取重构对象）
 *@Author Anzia.
 *@Date 2021/4/9 14:42
 *@Version 1.0
 **/
public class ObjectInputStream_Demo {

    public static void main(String[] args) throws Exception {

        //创建对象流
        FileInputStream fis = new FileInputStream("static\\stu.bin");
        ObjectInputStream ois = new ObjectInputStream(fis);

        //读取文件（反序列化）
        //com.anzia.stream.Student student = (com.anzia.stream.Student)ois.readObject();
        ArrayList<String> list =(ArrayList<String>) ois.readObject();

        //关闭
        ois.close();
        System.out.println("反序列化执行完毕！");
        //System.out.println(student.toString());
        System.out.println(list.toString());

    }

}
